<?php
if($use_username)
    $username = array('id' => 'username', 'name' => 'username', 'value' => set_value('username'), 'size' => 30, 'maxlength' => $this->config->item('username_max_length', 'tank_auth'));

$email = array('id' => 'email', 'name' => 'email', 'value' => set_value('email'), 'size' => 30, 'maxlength' => 80);
$password = array('id' => 'password', 'name' => 'password', 'value' => set_value('password'), 'size' => 30, 'maxlength' => $this->config->item('password_max_length', 'tank_auth'));
$confirm_password = array('id' => 'confirm_password', 'name' => 'confirm_password', 'value' => set_value('confirm_password'), 'size' => 30, 'maxlength' => $this->config->item('password_max_length', 'tank_auth'));
$captcha = array('id' => 'captcha', 'name' => 'captcha', 'maxlength' => 8);
$submit = array('class' => 'btn btn-success', 'name' => 'register', 'value' => lang('auth_submit'));

echo form_open($this->uri->uri_string());
?>

<div class="page-header">
    <h3><?php echo lang('auth_register'); ?></h3>
</div>

<p>
    <?php if($use_username): ?>
    <span class="form-inline">
        <?php
        echo
        lang('auth_username', $username['id']).form_input($username).
        form_error($username['name'], '<span class="alert">', '</span>');
        if(isset($errors[$username['name']]))
            echo '<span class="alert">'.$errors[$username['name']].'</span>';
        ?>
    </span>
    <?php endif; ?>

    <span class="form-inline">
        <?php
        echo
        lang('auth_email', $email['id']).form_input($email).
        form_error($email['name'], '<span class="alert">', '</span>');
        if(isset($errors[$email['name']]))
            echo '<span class="alert">'.$errors[$email['name']].'</span>';
        ?>
    </span>
    <span class="form-inline">
        <?php
        echo
        lang('auth_password', $password['id']).form_password($password).
        form_error($password['name'], '<span class="alert">', '</span>');
        if(isset($errors[$password['name']]))
            echo '<span class="alert">'.$errors[$password['name']].'</span>';
        ?>
    </span>
    <span class="form-inline">
        <?php
        echo
        lang('auth_confirm_password', $confirm_password['id']).form_password($confirm_password).
        form_error($confirm_password['name'], '<span class="alert">', '</span>');
        if(isset($errors[$confirm_password['name']]))
            echo '<span class="alert">'.$errors[$confirm_password['name']].'</span>';
        ?>
    </span>
</p>

<?php
if($captcha_registration) {
    if($use_recaptcha):
    ?>

    <div id="recaptcha" class="clearfix">
        <p id="recaptcha_image"></p>
        <p id="recaptcha_other">
            <a href="javascript:Recaptcha.reload()"><?php echo lang('auth_get_another_captcha'); ?></a><br />
            <a class="recaptcha_only_if_image" href="javascript:Recaptcha.switch_type('audio')"><?php echo lang('auth_get_audio_captcha'); ?></a>
            <a class="recaptcha_only_if_audio" href="javascript:Recaptcha.switch_type('image')"><?php echo lang('auth_get_image_captcha'); ?></a>
        </p>
    </div>

    <p>
        <span class="form-inline">
            <?php
            echo
            form_label(lang('auth_enter_words'), 'recaptcha_response_field', array('class' => 'recaptcha_only_if_image')).
            form_label(lang('auth_enter_numbers'), 'recaptcha_response_field', array('class' => 'recaptcha_only_if_audio')).
            form_input(array('id' => 'recaptcha_response_field', 'name' => 'recaptcha_response_field'));
            ?>
        </span>
        <?php
        echo
        form_error('recaptcha_response_field', '<span class="form-inline alert">', '</span>').
        $recaptcha_html;
        ?>
    </p>

    <?php
    else:
    ?>

    <p><?php echo lang('auth_enter_captcha_code'); ?></p>
    <p><?php echo $captcha_html; ?></p>
    <p>
        <span class="form-inline"><?php echo lang('auth_confirmation_code', $captcha['id']).form_input($captcha); ?></span>
        <span class="form-inline alert"><?php echo form_error($captcha['name'], '<span class="error">', '</span>'); ?></span>
    </p>

    <?php
    endif;
}
?>

<p class="form-actions"><?php echo form_submit($submit); ?></p>

<?php form_close(); ?>